// Fill out your copyright notice in the Description page of Project Settings.


#include "CustomMeshActor.h"

// Sets default values
ACustomMeshActor::ACustomMeshActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	mesh_ = CreateDefaultSubobject<UCustomMeshComponent>(TEXT("CustomMesh"));
	RootComponent = mesh_;

	FCustomMeshTriangle tri;
	tri.Vertex0 = FVector(0, 0, 0);
	tri.Vertex1 = FVector(0, 50, 50);
	tri.Vertex2 = FVector(0, 0, 50);

	TArray<FCustomMeshTriangle> triangles;
	triangles.Add(tri);
	mesh_->SetCustomMeshTriangles(triangles);

	static ConstructorHelpers::FObjectFinder<UMaterial> mat(TEXT("Material'/Game/CustomMesh/CustomMesh_mat'"));
	if (mat.Object) {
		mesh_->SetMaterial(0, mat.Object);
	}
}

// Called when the game starts or when spawned
void ACustomMeshActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ACustomMeshActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}
